<?php

namespace Home\Controller;


use Think\Controller;

class LoginController extends Controller
{

    public function index()
    {
        if (IS_POST) {
            $map['email'] = I('post.email');
            $map['pwd']   = md5(I('post.pwd'));
            if ($user = D('register')->where($map)->find()) {
                unset($user['pwd']);
                session('userinfo', $user['email']);
                session('userpic', $user['pic']);
                // dump($user['pic']);die;
                session('isLogin', 1);
              
                $this->success('欢迎回来', U('Index/index'));
            } else {
                $this->error('账号或密码不正确');
            }
        } else {
            $this->display();
        }

    }

    public function logout()
    {
        session(null);
        $this->success('退出成功',U('Index/index'));
        // $user['email']="欢迎登录";
        // session('userinfo', $user['email']);
        
       
    }

}
